/**
 * File TestUserTextMessage.java 
 */
package cstest.entity;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import cs.entity.User;
import cs.entity.UserTextMessage;

/**
 * Package  cstest.entity
 * Project ChatSystemG1 - INSA 4INFOA1 - 2013/2014
 * @author Julie DUMONS & Juste OUEDRAOGO
 *
 */
public class TestUserTextMessage {

	User u1, u2 ; 
	String m1, m2 ; 
	UserTextMessage utm1, utm2 ; 

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		u1 = new User() ; 
		u2 = new User() ; 
		m1 = "message1" ; 
		m2 = "message2" ;
		utm2 = new UserTextMessage(u1, m1) ; 

	}

	/**
	 * @throws java.lang.Exception
	 */
	@After
	public void tearDown() throws Exception {
		u1 = null ; 
		u2 = null ; 
		m1 = null ; 
		m2 = null ; 
		utm2 =  null ;
		
	}

	/**
	 * Test method for {@link cs.entity.UserTextMessage#UserTextMessage(cs.entity.User, java.lang.String)}.
	 */
	@Test
	public void testUserTextMessage() {
		assertNull(utm1) ; 
		utm1 = new UserTextMessage(u1, m1) ; 
		assertNotNull (utm1) ; 
		assertSame(utm1.getMessage(), m1) ; 
		assertSame(utm1.getRemoteUser(), u1); 
		
	}

	/**
	 * Test method for {@link cs.entity.UserTextMessage#getRemoteUser()}.
	 */
	@Test
	public void testGetRemoteUser() {
		assertSame(utm2.getRemoteUser(), u1); 
	}

	/**
	 * Test method for {@link cs.entity.UserTextMessage#setRemoteUser(cs.entity.User)}.
	 */
	@Test
	public void testSetRemoteUser() {
		assertNotSame(utm2.getRemoteUser(), u2);
		utm2.setRemoteUser(u2)	;
		assertSame(utm2.getRemoteUser(), u2);

		}

	/**
	 * Test method for {@link cs.entity.UserTextMessage#getMessage()}.
	 */
	@Test
	public void testGetMessage() {
		assertSame(utm2.getRemoteUser(), u1); 
	}

	/**
	 * Test method for {@link cs.entity.UserTextMessage#setMessage(java.lang.String)}.
	 */
	@Test
	public void testSetMessage() {
		assertNotSame(utm2.getMessage(), m2);
		utm2.setMessage(m2)	;
		assertTrue(utm2.getMessage().equals(m2));
	}

}
